- /* simncvdc.cpp by K.Tsuru */
- // function ID = 413 BRADIX
- /***************************************************************************
- SInteger class
- It provides a normal radix conversion.
- BRADIX ---> DRADIX
- The processing time is proportional to the square of the number of figures.
- ***************************************************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- SLong SInteger::NConvToDec() const{
- SLong result;
- uint szD = Head()+1u;
- if(szD <= 2u){ //under two figures including zero
- long v = (long)figure(1)*BRADIX + (long)figure(0);
- if(Sign() < 0) v = -v;
- result.SetLong(v);
- return result;
- }
-
- SInteger a(*this);
- uint szB = uint( (double)szD*log10((double)BRADIX)/DFIGURES )+ 1u; // ver.2.17
- result.FigureAlloc(szB, -1);
- fType* rv = result.figure.Elements();
- if(a.Sign() < 0) a.ChangeSign();
-
- register uint j = 0;
- while(a.Sign()){
- rv[j++] = (fType)IsDiv(a, DRADIX, a); //a /= DRADIX; rv[j]=a%DRADIX;
- }
- #ifndef NDEBUG
- result.figure(j-1);
- #endif
- result.figure.clear(j);
- result.aHead = j-1; // j >= 1
- j = 0;
- while(rv[j] == 0) j++;
- result.aTail = j;
- result.SetSign( Sign() );
- result.CutDown(result.POP);
- if( 2u*(result.aHead+1) <= result.figure.size() ) result.DoCutDown();
- return result;
- }
simncvdc.cpp : last modifiled at 2017/03/13 14:32:00(1,302 bytes)
created at 2016/04/25 14:53:17
The creation time of this html file is 2017/10/25 11:09:45 (Wed Oct 25 11:09:45 2017).